(function(){
	if (loadItem("web3js_wallet")){
		if(!confirm("您已经有一个内置账号了，想要重新创建吗？")) return;
	}
	getNode("pswd1").onkeyup=function(){
		if (checkPassword(this.value)) getNode("ok").onclick = go;
		else getNode("ok").onclick = "";
	}
	//显示或隐藏密码
	setEye(1);
	setEye(2);
	async function go(){
		var pswd1=getNode("pswd1").value;
		var pswd2=getNode("pswd2").value;
		if (pswd1!=pswd2){
			setNodeText("errmsg","验证密码不一致");
			return;
		}
		display("before",false);
		setLoading(1);
		//根据密码随机生成一个内置钱包
		var wallet = await newWallet(pswd1);
		setLoading(0);
		display("after",true);
		getNode("pubAddress").innerText = publicParam.address;
		getNode("mnemonic").innerText = wallet.mnemonic.phrase;
		//连接钱包
		getNode("finish").onclick=()=>{
            connectWallet(wallet);
			goto("home");
		};
	};
})();